Method for rebalancing data partitions

ABSTRACT

Embodiments of the present invention disclose a method, computer program product, and system for rebalancing partitioned data based, at least in part, on one or more characteristics of the plurality of database partitions. The computer updating characteristics, wherein the one or more characteristics include one or both of a) an average number of records per partition, and b) an average number of unique limit key values per partition. 
     Embodiments of the present invention disclose a method, computer program product, and system for limit key extrapolation in a database. Responsive to a determination that the upper limit key value of the last loaded record is greater than the first upper limit key value of the first empty partition, the computer redefines the first upper limit key value of the first empty partition by an extrapolated upper limit key value based, at least in part, on the range of limit key values.

BACKGROUND

The present invention relates generally to the field of databasemanagement and more particularly to rebalancing partitioned data in adatabase management system.

A partitioned database environment is a database installation allowingdata distribution across two or more divisions with each division acrossone or more nodes. Relational database management systems (RDBMS) storedata in database tables that are conceptually organized into records orrows with multiple columns, but may physically be separated into partsalong either row or column boundaries between partitions. As records areadded or removed from a partitioned table, the size of the partitionschange. Over time, the partitions can become unbalanced with thepartitions containing highly skewed distributions of data. Databaseadministrators perform reorganization or rebalancing of databasepartitions to balance the usage of storage space, improve databasesystem performance, or satisfy various system requirements.

Database tables are divided into partitions based on a boundary value,distribution key, or limit key which is typically a customer specifiedfield or column within each row of data used to divide multiple rows ofdata. The starting (lowest) and ending (highest) limit key value definesa range of a partition, but the partition is typically referred to bythe upper limit key. Partitioning rules require that all records for asingle limit key value reside together within the same partition. Thedecision to set the range for each partition may be calculated based onthe total number of data records to be loaded into the database, basedon customer specific requirements, or some combination thereof. Besidesrange partitioning as shown in the example, other forms of partitioninginclude list partitioning, hash partitioning, and compositepartitioning.

Even though tables are divided up into partitions which may reside onseparate computers, the data may be accessed efficiently andconveniently in response to Structured Query Language (SQL) statements,such as SELECT, INSERT, DELETE, and UPDATE. The fact that databases aresplit across database partitions is transparent to users issuing SQLstatements or commands. Because each partition may be on a separatephysical machine, the processor on each machine is used by the databasemanager at each partition to manage the part of the total data in thedatabase residing on that machine. Data partitions allow for parallelprocessing and faster execution of data requests while the user can senda data request without needing to know the specifics of the partitioningof the database.

SUMMARY

Embodiments of the present invention disclose a method, computer programproduct, and system for rebalancing partitioned data in a database. Acomputer initiating a rebalance of a set of data records included in aplurality of database partitions by unloading the set of data records,wherein the rebalance of the set of data records is improved based, atleast in part, on one or more characteristics of the plurality ofdatabase partitions that are determined during the rebalance of the setof data records. The computer updating the one or more characteristicsduring the rebalancing of the set of data records, wherein the one ormore characteristics include one or both of a) an average number ofrecords per partition, and b) an average number of unique limit keyvalues per partition. The computer loading the set of data records intothe plurality of database partitions based, at least in part, on the oneor more characteristics, wherein the one or more characteristics areused to direct the rebalancing of the set of data records.

Embodiments of the present invention disclose a method, computer programproduct, and system for limit key extrapolation in a database.Responsive to a determination that the upper limit key value of the lastloaded record is greater than the first upper limit key value of thefirst empty partition, the computer redefines the first upper limit keyvalue of the first empty partition by an extrapolated upper limit keyvalue based, at least in part, on the range of limit key values.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

FIG. 1 is a functional block diagram illustrating a distributed dataprocessing environment, in accordance with an embodiment of the presentinvention.

FIG. 2A is an example of adaptive rebalancing of a partitioned database,in accordance with an embodiment of the present invention.

FIG. 2B is an example of limit key extrapolation during rebalancing of apartitioned database, in accordance with an embodiment of the presentinvention.

FIG. 3A is a flowchart depicting the operational steps of a relationaldatabase management system for rebalancing a partitioned database usingadaptive rebalancing by the average number of records per partition andusing limit key extrapolation, in accordance with an embodiment of thepresent invention.

FIG. 3B is a flowchart depicting additional operational steps of arelational database management system for rebalancing a partitioneddatabase using adaptive rebalancing by the average number of uniquelimit key values per partition and using limit key extrapolation, inaccordance with an alternate embodiment of the present invention.

FIG. 4 depicts a block diagram of components of an exemplary computersystem for implementing embodiments of the present invention.

DETAILED DESCRIPTION

Embodiments of the present invention recognize that rebalancing ofdatabase partitions with heavily skewed data distributions may result inlater partitions without records. Database partitions are divided basedon a boundary value, or limit key typically defined by a customerspecified data field or record column within each row of data. Currentrelational database management systems (RDBMS) use a rebalance techniquethat calculates an average number of records per partition which theRDBMS applies to each rebalanced partition. If one partition is loadedwith more records than the calculated average number of records perpartition due to rules regarding keeping all records for a unique limitkey value within a single partition, then the remaining records may notbe evenly distributed among the remaining partitions, and emptypartitions will result at the end of rebalancing. Embodiments of thepresent invention provide for adaptive rebalancing of databasepartitions by recalculating the average number of records per partitionafter each partition is filled during the rebalance operation with thepurpose of ensuring records remain to load into the final partition.Empty partitions may, under certain conditions, produce a rebalancefailure which causes a loss of time and resources, but also, havingempty partitions defeats the goal of redistributing the records evenlyamong the partitions.

Embodiments of the present invention recognize that rebalancing ofdatabase partitions of highly skewed data distributions using only theaverage number of records per partition may result in running out ofrecords to distribute to later partitions. Embodiments of the presentinvention provide for adaptive rebalancing of database partitions whichrecalculates the average number of unique limit key values per partitionafter each partition is filled during the rebalance operation with thepurpose of ensuring records remain to load into the final partition. Inother embodiments, adaptive rebalancing of database partitions may useboth the average number of records per partition, and the average numberof unique limit key values per partition during the rebalance operationto ensure records remain to load into the final partition.

Current relational database management systems fail during rebalancingoperations if empty partitions remain after all records have beenreloaded. Embodiments of the present invention recognize that preventingfailure of a rebalance operation will reduce human resource hoursinvolved with failure analysis and re-coding, and reduce wastedcomputing resources on a failed rebalance operation. Empty partitionsmay occur when rebalancing results are less than optimal due to highlyskewed data distributions, or when the number of unique limit key valuespresent in the data is less than the number of partitions to be filled.Embodiments of the present invention provide for extrapolation of limitkeys to be used to define empty partitions after all records have beenreloaded to prevent failure of a rebalance operation.

Implementation of embodiments of the invention may take a variety offorms, and exemplary implementation details are discussed subsequentlywith reference to the figures. The illustrated embodiment describes aseries of commands that can be expressed as query statements, using SQLas the query language. Specific details disclosed herein are not to beinterpreted as limiting, but merely as a representative basis forteaching one skilled in the art to variously employ the methods andstructures of the present disclosure. Embodiments of the presentinvention may apply to all database types, including but not limited torelational, hierarchical, network, and object-oriented databases.Likewise, embodiments of the present invention may apply to other querylanguages, including but not limited to SQL, QUEL, OQL, and SEQUEL.

The present invention will now be described in detail with reference tothe Figures. FIG. 1 is a functional block diagram illustrating adistributed data processing environment, generally designated 100, inaccordance with an embodiment of the present invention. Distributed dataprocessing environment 100 includes server computers 102, 104, and 106,and client computer 108, interconnected over network 110. Distributeddata processing environment 100 may include additional server computers,client computers, or other devices not shown.

Network 110 can be, for example, a local area network (LAN), a wide areanetwork (WAN) such as the Internet, or a combination of the two, and caninclude wired, wireless, fiber optic, or any other connection known inthe art. In general, network 110 can be any combination of connectionsand protocols that may support communications between server computers102, 104, and 106, and client computer 108, in accordance with a desiredembodiment of the present invention.

Server computers 102, 104, and 106 can each respectively be a servercomputer, an application server, a laptop computer, a tablet computer, anetbook computer, a personal computer (PC), a desktop computer, apersonal digital assistant (PDA), a smart phone, or any programmableelectronic device capable of communicating with client computer 108, andthe remaining server computers via network 110. In certain embodiments,server computers 102, 104, and 106 can each respectively represent acomputer system utilizing clustered computers and components that act asa single pool of seamless resources when accessed through network 110,as is common in data centers and with cloud computing applications.Server computers 102, 104, and 106 may each be a node in a distributeddatabase management environment. In general, server computers 102, 104,and 106 can each respectively be representative of any computing deviceor a combination of devices with respective access to relationaldatabase management system 300, partitions 116, 118, and 120, andpartitions 116′, 118′, and 120′, and are respectively capable ofexecuting relational database management system 300. Server computers102, 104, and 106 may each include internal and external hardwarecomponents, as depicted and described in further detail with respect toFIG. 4.

Server computer 102 includes an instance of relational databasemanagement system 300 and a connection to database partitions 116, 118,and 120 via network 110. In the depicted environment, relationaldatabase management system 300 uses a user interface, such as UI 114, toreceive user input, and to output responses to a user, such as adatabase administrator. In the depicted environment, relational databasemanagement system 300 may be a suite of database management softwareapplications that interact with a user via UI 114, other applicationssuch as client application 122, and one or more databases to allow thedefinition, creation, querying, update, and administration of databases.Relational database management system 300 has the capability to create,fill, and rebalance partitions of a database, such as partitions 116,118, and 120, within distributed data processing environment 100.Relational database management system 300 performs partition rebalancingby unloading or extracting data from partitions 116, 118, and 120,sorting the extracted data, and reloading the transformed data intopartition copies, such as partitions 116′, 118′, and 120′. Once thepartition copies are updated with any intermittent changes, allapplications are directed to point to the new partitions 116′, 118′, and120′. Relational database management system 300 may perform other taskssuch as creating and publishing reports, updating indices or databasestatistics from the rebalanced database after the partition rebalancetask is finished. A database partition rebalance operation performed byrelational database management system 300 is described further in FIGS.3A and 3B.

In other embodiments of the present invention, relational databasemanagement system 300, partitions 116, 118, and 120, and partitions116′, 118′, and 120′, may be on one computer, or more than one computer,and each item itself may be split into a plurality of parts or modulesand spread across more than one computer. In any configuration, thefollowing is maintained: relational database management system 300communicates with partitions 116, 118, and 120, and new partitions 116′,118′, and 120′.

Relational database management system 300 enables the addition, update,or deletion of database records within partitions, such as partitions116, 118, and 120. Partitions may divide database tables by rows calledrecords, or by columns within rows. In the illustrative embodiment ofFIG. 1, the database is divided by rows, where each row contains a datafield in a column that is designated as a limit key. A limit key mayalso be referenced to as a partitioning key, boundary key, ordistribution key. The limit key may be specified by the databaseadministrator, and is typically based on customer specification forseparation of data. The highest value of the limit key within apartition is referred to as the limit key for the partition. Forexample, the limit key may be a data field representing zip codes. In adatabase with three partitions, table rows with zip codes of 01000 to49999 are in partition 116, table rows with zip codes of 50000 to 79999are in partition 118, and table rows with zip codes of 80000 to 99999are in partition 120. The limit key (or upper bound) for partition 116is 49999, for partition 118 is 79999, and for partition 120 is 99999.

Server computer 102 includes an instance of partition 116, and iscoupled to server computers 104 and 106 via network 110. Server computer104 includes an instance of partition 118, and is coupled to servercomputers 102 and 106 via network 110. Server computer 106 includes aninstance of partition 120, and is coupled to server computers 102 and104 via network 110. In the illustrative embodiment, partition 116 is afirst partition, partition 118 is a second partition, and partition 120is a third partition within a relational database that comprisespartitions 116, 118, and 120.

Partitions 116′, 118′, and 120′, are new database partitions located onserver computer 102, 104, and 106 respectively. After rebalancing, therecords from partitions 116, 118, and 120 are redistributed among thenew partitions 116′, 118′, and 120′ to create as even a distribution ofthe records as possible depending on the nature of the data. The newpartitions 116′, 118′, and 120′ will replace the old partitions 116,118, and 120 in use, and at a later time, the old partitions 116, 118,and 120 will be deleted.

Relational database management system 300 includes a user interface,such as UI 114. UI 114 may utilize a web page application, a commandline processor, or any other graphical user interface (GUI). UI 114includes components used to receive input from a user and transmit theinput to relational database management system 300 residing on servercomputer 102. In an embodiment, UI 114 uses a combination oftechnologies and devices, such as device drivers, to provide a platformto enable users of server computer 102 to interact with relationaldatabase management system 300. In various embodiments, UI 114 receivesinput using a physical input device, such as a keyboard or mouse, via adevice driver that corresponds to the physical input device. In anembodiment of the present invention, relational database managementsystem 300 may receive a request to rebalance a partitioned databasefrom a user via UI 114.

In various embodiments of the present invention, client computer 108 canbe a laptop computer, a tablet computer, an application server, anetbook computer, a personal computer (PC), a desktop computer, apersonal digital assistant (PDA), a smartphone, or any programmableelectronic device capable of communicating with server computers 102,104, and 106 via network 110. In certain embodiments, client computer108 can represent a computer system utilizing clustered computers andcomponents that act as a single pool of seamless resources when accessedthrough network 110, as is common in data centers and with cloudcomputing applications. In general, client computer 108 can berepresentative of any computing device or a combination of devices withaccess to client application 122, and is capable of executing clientapplication 122.

Client computer 108 includes an instance of client application 122,which executes locally on client computer 108 and has the capability tocommunicate with relational database management system 300 on servercomputer 102 via network 110. In various embodiments, client application122 is an associated client application created by a vendor or developerof relational database management system 300 for use in a server-clientenvironment. In the depicted environment, client application 122 uses auser interface, such as UI 112, to receive user input, and to outputresponses to a user. In the depicted environment, client application 122is an application enabling authorized users, such as databaseadministrators, to request relational database management system 300 toperform some task, such as partition rebalancing, related to thedatabase composed of partitions 116, 118, and 120 residing respectivelyon server computers 102, 104, and 106. Client application 122 allowsusers or applications of client computer 108 to transmit queries or SQLcommands to the database, and to retrieve data from the database. Thequeries are written without the knowledge of which data records are onwhich of the multiple partitions. In other embodiments of the presentinvention, client application 122 may reside on the same computer asrelational database management system 300.

Client application 122 includes a user interface, such as UI 112. UI 112may utilize a web page application, a command line processor, or anyother graphical user interface (GUI). UI 112 includes components used toreceive input from a user and transmit the input to client application122 residing on client computer 108. In an embodiment, UI 112 uses acombination of technologies and devices, such as device drivers, toprovide a platform to enable users of client computer 108 to interactwith client application 122. In the various embodiments, UI 112 receivesinput using a physical input device, such as a keyboard or mouse, via adevice driver that corresponds to the physical input device.

In an embodiment of the present invention, client application 122residing on client computer 108 allows an authorized user, such as adatabase administrator, to send a request to relational databasemanagement system 300 on server computer 102 via network 110 torebalance the database comprised of partitions 116, 118, and 120. Inanother embodiment of the present invention, relational databasemanagement system 300 may receive the request to rebalance the databasefrom a user of server computer 102 via UI 114. Databases may comprisetwo or more partitions which may be combined into groups, but, forsimplicity, only three partitions are shown. A data set is a collectionof the contents from a database. A table space scan, or relational scan,is a method of scanning the data within a database without the use ofindexes. Relational database management system 300 performs a partitionrebalance by unloading data records into a data set via a table spacescan of partitions 116, 118, and 120, sorting the extracted data inascending order of the limit key, and reloading the sorted data into newpartitions 116′, 118′, and 120′ using adaptive rebalancing and ifnecessary, extrapolated limit keys.

After completion of the rebalance, applications accessing partitions116, 118, and 120 are shut down, the new partitions are updated with anyintermittent changes since the data extraction, database indices arerecreated based on the new partitions, and all data applications aredirected to point to new partitions 116′, 118′, and 120′. At some pointdetermined by the database administrator or by relational databasemanagement system 300, the old partitions are removed.

In an embodiment of the present invention, relational databasemanagement system 300 provides for adaptive rebalancing of databasepartitions by recalculating the average number of records per partitionduring the rebalance operation for the purpose of ensuring recordsremain to load into the final partition. An example of adaptiverebalancing using the average number of records per partition isdescribed further in FIG. 2A.

In an embodiment of the present invention, relational databasemanagement system 300 provides for extrapolation of limit keys forremaining empty partitions after all records have been loaded to preventfailure of a rebalance operation. An example of limit key extrapolationduring adaptive rebalancing is described further in FIG. 2B.

In an embodiment of the present invention, relational databasemanagement system 300 provides for adaptive rebalancing of databasepartitions by recalculating the average number of records per partitionduring the rebalance operation, and provides for extrapolation of limitkeys for remaining empty partitions after all records have been loaded.The operational flow of adaptive rebalancing by recalculating theaverage number of records per partition and of limit key extrapolationis described further in FIG. 3A.

In an alternate embodiment, relational database management system 300provides for adaptive rebalancing of database partitions byrecalculating the average number of unique limit keys per partition andby recalculating the average number of records per partition during therebalance operation, and also provides for extrapolation of limit keysfor remaining empty partitions after all records have been loaded. Theoperational flow of adaptive rebalancing using the average number ofunique limit keys per partition and average number of records perpartition, and of extrapolation of limit keys is described further inFIG. 3B.

FIG. 2A is an example of adaptive rebalancing of a partitioned database,in accordance with an embodiment of the present invention. In theillustrative embodiment, a relational database having 10 partitions and1000 total data records needs rebalancing. Before reloading, the datarecords are sorted by limit key in ascending order.

At the start of rebalancing the target average number of records perpartition is calculated to be 1000/10=100 records. In the calculation,the number of records may be rounded up. While loading partition 1, atotal of 190 records are loaded into the partition starting with therecords with the lowest limit key value first. If the total number ofrecords with the first limit key is less than 100, then the records forthe next limit key are loaded into partition 1 as well. Partition rulesdefine that the records for a single unique limit key are loaded withinthe same partition.

Since more than 100 records are loaded into partition 1, if the initialtarget of 100 records per partition is used throughout partitioning,then there will be too few records remaining to fill the finalpartitions. In an embodiment of the present invention, adaptiverebalancing provides for recalculating the target average number ofrecords per partition after each partition is filled. After partition 1is filled, 810 records remain for filling 9 partitions, such that thenew average number of records per partition is calculated to be 810/9=90records per partition.

Partition 2 is filled with 110 records, which is above the target of 90,and the average number of records per partition is recalculated to be700/8=88 records per partition. Partition 3 is filled with 100 records,which is above the target of 88, and the average number of records perpartition is recalculated to be 600/7=86 records per partition.Partition 4 is filled with 130 records, which is above the target of 86,and the average number of records per partition is recalculated to be470/6=78 records per partition.

This continues through partitions 5 through 10, recalculating theaverage number of records per partition each time. Note by partition 7,the average is down to 60 records per partition, much less than theinitial starting point of 100 records per partition. The finalpartition, partition 10, receives 45 records during reload which wouldnot have happened without the adaptive rebalancing method. The adaptiverebalancing method using the recalculation of the average number ofrecords per partition allows for rebalancing of partitions with a moreeven distribution of data records.

FIG. 2B is an example of limit key extrapolation during rebalancing of apartitioned database, in accordance with an embodiment of the presentinvention. In the illustrative embodiment, a relational database having10 partitions and 1000 total data records needs rebalancing. Beforereloading, the data records are sorted by limit key in ascending order.

At the start of rebalancing the target average number of records perpartition is calculated as the total number of records divided by thetotal number of partitions, for example, 1000/10=100 records. Whileloading partition 1, a total of 200 records are loaded into thepartition starting with the records with the lowest limit key first.Partition rules define that all records for a single limit key are to beloaded within the same partition. In an embodiment of the presentinvention, adaptive rebalancing provides for recalculating the targetaverage number of records per partition after each partition is filled.All 200 records loaded into partition 1 are from limit key 1, and theaverage number of records per partition is recalculated as the number ofremaining records to be loaded divided by the remaining emptypartitions, for example, 800/9=89 records per partition.

Partition 2 is filled with 300 records from limit key 2, which is abovethe target of 89, and the average number of records per partition isrecalculated to be 500/8=63 records per partition. Partition 3 is filledwith 150 records from limit key 3, which is above the target of 63, andthe average number of records per partition is recalculated to be350/7=50 records per partition. Partition 4 is filled with 180 recordsfrom limit key 4, which is above the target of 50, and the averagenumber of records per partition is recalculated to be 170/6=28 recordsper partition. Partition 5 is filled with the remaining 170 recordswhich are all from limit key 5. There is no need to recalculate theaverage records per partition since no records remain.

Up to this point, the method of adaptive rebalancing has provided forthe number of records to be distributed as evenly across all partitionsas possible given the heavily skewed distribution of existing limit keyvalues in the data records. However, the five empty remaining partitionscauses an unrecoverable error in the rebalance operation, and the timeto perform the rebalance operation to this point would be wasted. Therebalance error happens when the last loaded record has a limit keyvalue higher than the previously defined upper limit key for the firstempty partition. Without limit key extrapolation, relational databasemanagement system 300 cannot define upper limit keys for each emptypartition, because relational database management system 300 may onlyuse the limit keys actually present in the reloaded data set.Embodiments of the present invention provide relational databasemanagement system 300 with the range of values of the limit keys asdefined in the system catalog, and enable relational database managementsystem 300 to define upper limit keys for empty partitions with valueswhich do not exist in the reloaded data set.

Embodiments of the present invention provide for a way to extrapolatelimit key values for the remaining empty partitions to prevent therebalance from failing. Limit key extrapolation provides a way to fillin sensible limit key values for the empty data partitions and stillenforce the rule of ascending limit key values. If the limit key valueof the last loaded record is higher than the previously defined limitkey values (before rebalancing) of the remaining empty partitions, thenthe remaining partitions require limit key extrapolation. The specificmethod of limit key extrapolation depends on the limit key column datatype, which can be, for example, numeric, date/timestamp, or character.

In the example of FIG. 2B, the data type is numeric, such as a smallinteger, and is defined at table creation to have a range of 1 to 25.Embodiments of the present invention, provide for relational databasemanagement system 300 to have access to the range information for thelimit key prior to the reload portion of the rebalance operation, eitherduring the unload or sort phase. To extrapolate limit keys for theremaining partitions, relational database management system 300calculates the arithmetic average number of remaining limit keys perremaining partitions. The arithmetic average is calculated to be (20remaining limit keys)/(5 remaining partitions)=(4 limit keys perpartition). Therefore, each remaining partition should be assigned 4limit keys. For example, adding the average number of remaining limitkeys to the last used limit key, 4+5=9, means that partition 6 isdefined to cover limit keys 6 through 9. Next, calculating 4+9=13, meansthat partition 7 covers limit keys 10 through 13. Calculating 4+13=17,means that partition 8 covers limit keys 14 through 17. In the same way,partition 9 covers limit keys 18 through 21, and partition 10 coverslimit keys 22 through 25. In this way each empty partition is definedwith limit key values so that future data corresponding to limit keysfrom 6 to 25 has somewhere to go in the partitions of the database.

If the limit key of the last loaded record is lower than the previouslydefined limit key values (before rebalancing) of the remaining emptypartitions, then the remaining partitions may keep the previouslydefined limit keys, and nothing else needs to be done.

The use of limit key extrapolation allows the rebalance to finishwithout error. If the customer or database administrator wishes to havedifferent limit key values applied to the empty partitions, thenrelational database management system 300 allows for the limit keyvalues of each partition to be reviewed and altered manually. The manualupdates may be through commands, such as SQL commands, sent by eitherclient application 122 on client computer 108, or by relational databasemanagement system 300 on server computer 102.

FIG. 3A is a flowchart depicting the operational steps of a relationaldatabase management system for rebalancing a partitioned database usingadaptive rebalancing by the average number of records per partition andusing limit key extrapolation, in accordance with an embodiment of thepresent invention.

Initially, relational database management system 300 receivescredentials from a user of server computer 102 or client computer 108for validation. Relational database management system 300 validates thatthe user has the authority to access the database and the authority torequest performance of administrative tasks. Responsive to determiningthat the user has the proper authority, relational database managementsystem 300 performs any requested tasks. If the user does not have theproper authority, then no access will be granted, and no tasks will beperformed. Relational database management system 300 provides thedatabase connections, and enables users of client application 122 onclient computer 108, or relational database management system 300 onserver computer 102 to issue commands for performing tasks on thedatabase.

Relational database management system 300 on server computer 102receives a request to rebalance partitions 116, 118, and 120 residing onserver computers 102, 104, and 106, respectively (step 302). The requestmay come from a user, such as a database administrator, via clientapplication 122 on client computer 108 via network 110, or viarelational database management system 300 on server computer 102. Arebalance operation may be on all partitions of a database, on a groupof partitions of a database, or some selected set of partitions within adatabase, as defined in the request.

Relational database management system 300 unloads all records frompartitions in the current database (step 304). In the illustrativeembodiment, all records from partitions 116, 118, and 120 are unloaded,such as through a table space scan. Unload means a copy of the recordsare stored in a memory or other storage location accessible torelational database management system 300, other than partitions 116,118, and 120.

Relational database management system 300 records start time in changelog to track interim changes in current database (step 306). The log isused to record the date and time of all changes to the databaseincluding, but not limited to, adding, updating, or deleting rows orrecords in the database. The start time may be recorded in the changelog, or in another data store connected to relational databasemanagement system 300 for reference at the end of the rebalance processin step 328.

Relational database management system 300 calculates the average numberof records per partition (step 308) to be used as an initial targetduring loading of new partitions 116′, 118′, and 120′. At the start ofrebalancing, the average number of records per partition is calculatedas the total number of records to be loaded divided by the total numberof partitions to be loaded. This value may be rounded up as necessary.

Relational database management system 300 determines the defined rangeof the limit key values used in partitions 116, 118, and 120 (step 310).The limit key values actually used in the current partitions may only bea sub-set of the values available. When the database table is created,the range of the limit key value may be set by a customer specification,and entered by the database administrator. This range may be stored insome part of the database, such as the system catalog, or in a separatedata store accessible to relational database management system 300 foruse later in step 324.

Relational database management system 300 sorts the unloaded records inascending order of limit key value (step 312). This sort may be part ofthe unload process or may be done at any time prior to the reloadoperation. In other embodiments, the records may not be physicallysorted, and instead the loading process utilizes an index of the recordsthat enables loading in ascending order of limit key into the newpartitions. In the case of character data, the records may be sorted inalphabetical order.

Relational database management system 300 loads records into a partitionuntil partition cut off is reached (step 314). When loading a newpartition, records are loaded starting with the records with the lowestlimit key value first, and all records for a single limit key value areloaded within the same partition. By following that rule, somepartitions are filled with more records than the average number ofrecords per partition due to the amount of data associated with thelimit key. After the records for a limit key are loaded into apartition, if the total number of records loaded in the partition isless than the average number of records per partition as calculated instep 308, then the records for the next limit key are loaded into thepartition. Records for each subsequent limit key are loaded into thepartition until the total number of records loaded into the partition atleast equals or exceeds the average number of records per partition. Atthis point, the partition is filled, partition cut off is reached, andrelational database management system 300 stops loading into the currentpartition, and moves to the next partition.

Relational database management system 300 recalculates the averagenumber of records per partition after each partition cut off (step 316).When more records are loaded into a partition than the average number ofrecords per partition, and if the initial target of records perpartition calculated in step 308 were used throughout partitioning, thenthere would be too few records remaining to fill the final partitions.In an embodiment of the present invention, adaptive rebalancing providesfor recalculating the average number of records per partition after eachpartition is filled. Responsive to determining a partition is filled,relational database management system 300 recalculates the new averagenumber of records per partition by taking the number of remainingrecords to be loaded divided by the remaining empty partitions. Usingthe updated average as the target number of records for filling the nextpartition, adaptive rebalancing helps to smooth out an un-even datadistribution across all partitions, and helps increase the likelihood ofhaving at least one grouping of data records with one limit key valuefor loading into the last partition.

Relational database management system 300 determines if all records havebeen loaded (decision block 318). If relational database managementsystem 300 determines all records have been loaded (yes branch, decisionblock 318), then relational database management system 300 determines ifempty partitions remain after all records have been loaded (decisionblock 320). If relational database management system 300 determines allrecords have not been loaded (no branch, decision block 318), thenrelational database management system 300 loads records into a partitionuntil partition cut off is reached (step 314). Relational databasemanagement system 300 continues filling the next partition untilpartition cut off is reached (step 314), and recalculating the averagenumber of records per partition after each partition cut off (step 316)until all data has been loaded. Partitions are loaded in sequence, suchas partition 116′, then partition 118′, and finally partition 120′.

Relational database management system 300 determines if empty partitionsremain after all records have been loaded (decision block 320). Ifrelational database management system 300 determines empty partitions donot remain after all records have been loaded (no branch, decision block320), then relational database management system 300 shuts down accessto the current database (step 326). If no empty partitions remain, thenlimit key extrapolation is not required, and relational databasemanagement system 300 begins preparations for the switchover to the newpartitions.

If relational database management system 300 determines empty partitionsdo remain after all records have been loaded (yes branch, decision block320), then relational database management system 300 determines if thelimit key of the last loaded record is higher than the previous limitkey values of empty partitions (decision block 322). If relationaldatabase management system 300 determines that the limit key of the lastloaded record is not higher than the previous limit key values of emptypartitions (no branch, decision block 322), then relational databasemanagement system 300 shuts down access to the current database (step326). If the limit key of the last loaded record is less than thepreviously defined limit key values bounding the empty partitions, thenthe empty partitions may keep the previous limit key values they hadbefore the rebalancing. As long as limit key values are maintained inascending order, no limit key extrapolation is needed, and relationaldatabase management system 300 begins preparations for the switchover tothe new partitions.

If relational database management system 300 determines that the limitkey of the last loaded record is higher than the previous limit keyvalues of empty partitions (yes branch, decision block 322), thenrelational database management system 300 extrapolates limit keys forempty partitions (step 324). Embodiments of the present inventionprovide for a method allowing relational database management system 300to extrapolate limit key values for the remaining empty partitions toprevent the rebalance operation from failing. Relational databasemanagement system 300 performs limit key extrapolation to fill in limitkey values for the empty data partitions and enforces the rule ofascending limit key values. Limits keys are defined at table creation tohave a specific range which was determined in step 310. In embodimentsof the present invention, relational database management system 300 hasaccess to the range information for the limit key prior to the reloadportion of the rebalance operation.

To extrapolate limit keys of numeric data types for the remaining emptypartitions, relational database management system 300 calculates anarithmetic average for the remaining partitions requiring limit keyvalues by dividing the remaining range of limit key values by a numberof empty partitions. Relational database management system 300calculates the remaining range of limit key values by subtracting thegreatest limit key value of the reloaded set of data records from thegreatest limit key value in the range of limit key values as defined forpartitions 116, 118, and 120. In various embodiments of the presentinvention, when limit key definitions are comprised of multiple columnsor fields in a record, only the first or leading column of the limit keydefinition is used in limit key extrapolation.

Relational database management system 300 adds the arithmetic average tothe last used limit key to define the upper limit key of the first emptypartition. A partition is defined, at least in part, by the upper limitkey. For example, when limit keys are whole numbers, and the last limitkey loaded into partition 7 was 10, then empty partition 8 would startat 10+1=11, and end at 10+5=15, if the arithmetic average is 5.Relational database management system 300 determines the upper limit keyrange for the remaining empty partitions by adding the arithmeticaverage to the last limit key of the previous partition.

The method of limit key extrapolation is dependent on the limit keycolumn data type, for example, numeric, date/timestamp, or character.Numeric data types for limit keys are including, but not limited to,integer, small integer, decimal, floating point, bigint, and decfloat.Relational database management system 300 determines the arithmeticaverage by dividing the remaining range of limit key values by thenumber of empty partitions.

To extrapolate limit keys of date/timestamp data types for the remainingempty partitions, relational database management system 300 calculates amid-range date/timestamp value using calculation by days. Relationaldatabase management system 300 determines the arithmetic average byconverting the remaining range of limit key values from date/timestampvalues into a number of days, and then dividing by the number of emptypartitions. Relational database management system 300 determines theupper limit key range for the remaining empty partitions by adding thearithmetic average in number of days to the last limit key of theprevious partition.

To extrapolate limit keys of character type for the remaining emptypartitions, relational database management system 300 converts thecharacter to a floating point value, calculates the arithmetic averageby dividing by the number of empty partitions, and reconverts thefloating point value to a character data type value. Relational databasemanagement system 300 determines the upper limit key range for theremaining empty partitions by adding the arithmetic average as afloating point number to the last limit key of the previous partition asa floating point number, and then converting the resultant floatingpoint number into a character.

Relational database management system 300 shuts down access to thecurrent database (step 326) comprised of partitions 116, 118, and 120.Relational database management system 300 stops all access to partitions116, 118, and 120 so that a switch to new partitions 116′, 118′, and120′, may be made without losing data transactions during theswitchover.

Relational database management system 300 updates the new database withany interim changes from the change log (step 328). In step 306, thestart time of the rebalance operation was recorded. Any changes to thedatabase partitions 116, 118, and 120 that happened between the time thedata records were unloaded and the shutdown of applications accessingthe current database, will be performed on the records that reside innew partitions 116′, 118′, and 120′. Relational database managementsystem 300 also performs any updates to indices of the database inrelation to the changes coming from the rebalance operation.

If the customer or database administrator wishes to have different limitkey values applied to the empty partitions than were created duringlimit key extrapolation, then relational database management system 300allows for the limit key values of each partition to be reviewed andaltered manually at this time. The manual updates may be throughcommands sent by either client application 122 on client computer 108,or by relational database management system 300 on server computer 102.

Relational database management system 300 switches applications to thenew database (step 330) comprised of new partitions 116′, 118′, and120′. All applications and users are switched to the new database, suchthat changes will now be performed on new partitions 116′, 118′, and120′. At some point, relational database management system 300 willdelete partitions 116, 118, and 120 from the database. This may bespecified by predefined cleaning procedures, or by the databaseadministrator as needed.

FIG. 3B is a flowchart depicting additional operational steps of arelational database management system for rebalancing a partitioneddatabase using adaptive rebalancing by the average number of uniquelimit key values per partition and using limit key extrapolation, inaccordance with an alternate embodiment of the present invention. In thealternate embodiment, additional odd-numbered steps of flow 350 areadded to flow 300 of FIG. 3A, and fit in numerical order between thesteps of FIG. 3A. These steps provide for adaptive rebalancing whichuses both recalculation of the average number of records per partition,and recalculation of the average number of unique limit key values perpartition.

Steps 302, 304, and 306 are performed as described above in FIG. 3A.

In a first embodiment of the present invention, relational databasemanagement system 300 determines the number of unique limit key valuesused in records from partitions 116, 118, and 120 (step 307). Relationaldatabase management system 300 may use various methods to determine thenumber of unique limit key values actually existing in partitions 116,118, and 120. In one embodiment of the present invention, if there is aunique index on the database partitions that is a super-set of the limitkey columns, then unloading the data records via an index scan of thatindex, and tracking the number of unique limit key values from the indexkey as data records are unloaded in sequence without sorting is possibleby relational database management system 300. This method provides anexact count of the number of unique limit key values, and removes thesort requirement after unload at step 312; however, the method can beresource expensive depending on the disorganization of the index,additional I/O is required, and the method may be non-universaldepending on the DDL definitions for the database.

In a second embodiment of the present invention, as relational databasemanagement system 300 unloads the data records via table space scan,relational database management system 300 may perform a hashingalgorithm on each extracted limit key value to come up with a roughestimate of the number of unique limit key values. This method may beprogrammed into the unload process, but the obtained number is only anestimate, and the hashing program is CPU intensive.

In a third embodiment of the present invention, as relational databasemanagement system 300 sorts the data records in step 312 by limit keyvalue, and as the records are returned from sort, relational databasemanagement system 300 may retrieve and compare the limit key values foreach record to keep count, and cache the retrieved records into astorage location, such as a basic sequential access method (BSAM) dataset or an in-memory buffer. After all records are pre-scanned,relational database management system 300 rereads the records from thestart to perform data reloading. This method provides an exact count ofthe number of unique limit key values, but costs performance overhead incaching and re-reading of the data records.

Step 308 is performed as described above in FIG. 3A.

Relational database management system 300 calculates an average numberof unique limit key values per partition (step 309). Filling partitionsbased on the average number of unique limit key values per partition maybe used to ensure that partitions do not exhaust all the unique limitkey values before filling the final partition.

Step 310 is performed as described above in FIG. 3A.

Relational database management system 300 initializes counters (step311). Relational database management system 300 creates and initializesa counter for the number of unique limit key values remaining, and acounter for the number of unique limit key values used in a partition.To aid in recalculating the number of unique limit key values perpartition, a counter is needed to keep track of how many unique limitkey values have been used in partitions, and how many remain for theremaining partitions. To aid in determining when to cut off loading datato a partition, a counter is needed to keep track of the number ofunique limit key values used in a partition. The partition counter isreset prior to the start of loading each new partition.

Step 312 is performed as described above in FIG. 3A.

Relational database management system 300 loads records into a partitionuntil partition cut off is reached (step 314). When loading a newpartition, records are loaded starting with the records with the lowestlimit key first, and all records for a single limit key are loadedwithin the same partition. By following that rule, some partitions arefilled with more records than the average number of records perpartition due to the nature of the data. Records are loaded intopartitions based on two limits: (1) the average number of records perpartition, and (2) the average number of unique limit key values perpartition. After the records for a limit key are loaded into apartition, if the total number of records loaded in the partition isless than the average number of records per partition as calculated instep 308, and if the total number of unique limit key values loaded intothe partition is less than the average number of unique limit key valuesper partition, then the records for the next limit key are loaded intothe partition. Records for each subsequent limit key are loaded into thepartition until either the total number of records loaded in thepartition equals or exceeds the average number of records per partition,or until the total number of unique limit key values loaded into thepartition equals the average number of unique limit key values perpartition. At this point, partition cut off is reached, and relationaldatabase management system 300 stops loading into the current partition.Relational database management system 300 resets the counter for thenumber of unique limit key values used in a partition.

Relational database management system 300 recalculates the averagenumber of unique limit key values per partition after each partition cutoff (step 315). In an embodiment of the present invention, adaptiverebalancing provides for recalculating the average number of uniquelimit key values per partition after each partition is filled.Relational database management system 300 recalculates the averagenumber of unique limit key values per partition by taking the number ofremaining unique limit key values to be loaded (from the counter)divided by the number of remaining empty partitions. By using this newaverage number of unique limit key values per partition, adaptiverebalancing spreads the data distribution more evenly across allpartitions. The number of remaining empty partitions is the same as theremaining number of database partitions to be filled.

In an alternate embodiment, relational database management system 300uses the initial value for the number of unique limit keys throughoutthe rebalancing, and does not recalculate this value. In that case, thecounter for the number of unique limit key values remaining is notneeded.

Step 316 is performed as described above in FIG. 3A.

Relational database management system 300 determines if all records havebeen loaded (decision block 318). If relational database managementsystem 300 determines all records have been loaded (yes branch, decisionblock 318), then relational database management system 300 determines ifempty partitions remain after all records have been loaded (decisionblock 320). If relational database management system 300 determines allrecords have not been loaded (no branch, decision block 318), thenrelational database management system 300 loads records into a partitionuntil partition cut off is reached (step 314). Relational databasemanagement system 300 continues loading records into a partition untilpartition cut off is reached (step 314), recalculating the averagenumber of unique limit key values per partition (step 315), andrecalculating the average number of records per partition after eachpartition cut off (step 316) until all data has been loaded.

Step 320 is performed as described above in FIG. 3A. Empty partitionsmay result when the number of unique limit key values is less than thenumber of partitions being reorganized.

Steps 322, 324, 326, 328, and 330 are performed as described above inFIG. 3A.

Alternate embodiments may exist that use one or more of the following:(1) method of adaptive rebalancing using recalculating the averagenumber of records per partition after each filled partition, (2) themethod of adaptive rebalancing using recalculating the average number ofunique limit key values per partition, and (3) the method of limit keyextrapolation for empty partitions.

FIG. 4 depicts a block diagram of respective components of servercomputers 102, 104, and 106, and client computer 108, in accordance withan illustrative embodiment of the present invention. FIG. 4 providesonly an illustration of one implementation and does not imply anylimitations with regard to the environments in which differentembodiments may be implemented. Many modifications to the depictedenvironment may be made.

Server computers 102, 104, and 106, and client computer 108 each includerespective communications fabric 402, which provides communicationsbetween computer processor(s) 404, memory 406, persistent storage 408,communications unit 410, and input/output (I/O) interface(s) 412.Communications fabric 402 can be implemented with any architecturedesigned for passing data and/or control information between processors(such as microprocessors, communications and network processors, etc.),system memory, peripheral devices, and any other hardware componentswithin a system. For example, communications fabric 402 can beimplemented with one or more buses.

Memory 406 and persistent storage 408 are computer readable storagemedia. In this embodiment, memory 406 includes random access memory(RAM) 414 and cache memory 416. In general, memory 406 can include anysuitable volatile or non-volatile computer readable storage media.

Relational database management system 300, partitions 116, 118, and 120,and client application 122 are stored in respective persistent storage408 for execution and/or access by one or more of the further respectivecomputer processors 404 via one or more memories of memory 406. In thisembodiment, persistent storage 408 includes a magnetic hard disk drive.Alternatively, or in addition to a magnetic hard disk drive, persistentstorage 408 can include a solid state hard drive, a semiconductorstorage device, read-only memory (ROM), erasable programmable read-onlymemory (EPROM), flash memory, or any other computer readable storagemedia that is capable of storing program instructions or digitalinformation.

The media used by persistent storage 408 may also be removable. Forexample, a removable hard drive may be used for persistent storage 408.Other examples include optical and magnetic disks, thumb drives, andsmart cards that are inserted into a drive for transfer onto anothercomputer readable storage medium that is also part of persistent storage408.

Communications unit 410, in these examples, provides for communicationswith other data processing systems or devices, including resources ofserver computers 102, 104, and 106, and client computer 108. In theseexamples, communications unit 410 includes one or more network interfacecards. Communications unit 410 may provide communications through theuse of either or both physical and wireless communications links.Relational database management system 300, partitions 116, 118, and 120,and client application 122 may be downloaded to respective persistentstorage 408 through communications unit 410.

I/O interface(s) 412 allows for input and output of data with otherdevices that may be connected to server computers 102, 104, and 106, andclient computer 108. For example, I/O interface 412 may provide aconnection to external device(s) 418 such as a keyboard, a keypad, atouch screen, and/or some other suitable input device. Externaldevice(s) 418 can also include portable computer readable storage mediasuch as, for example, thumb drives, portable optical or magnetic disks,and memory cards. Software and data used to practice embodiments of thepresent invention, e.g., relational database management system 300,partitions 116, 118, and 120, and client application 122, can be storedon such portable computer readable storage media and can be loaded ontorespective persistent storage 408 via I/O interface(s) 412. I/Ointerface(s) 412 also connect to a display 420.

Display 420 provides a mechanism to display data to a user and may be,for example, a computer monitor.

The present invention may be a system, a method, and/or a computerprogram product. The computer program product may include a computerreadable storage medium (or media) having computer readable programinstructions thereon for causing a processor to carry out aspects of thepresent invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Smalltalk, C++ or the like, andconventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

The programs described herein are identified based upon the applicationfor which they are implemented in a specific embodiment of theinvention. However, it should be appreciated that any particular programnomenclature herein is used merely for convenience, and thus theinvention should not be limited to use solely in any specificapplication identified and/or implied by such nomenclature.

It is to be noted that the term(s) “Smalltalk” and the like may besubject to trademark rights in various jurisdictions throughout theworld and are used here only in reference to the products or servicesproperly denominated by the marks to the extent that such trademarkrights may exist.

What is claimed is:
 1. A method for rebalancing partitioned data in adatabase, the method comprising: a computer initiating a rebalance of aset of data records included in a plurality of database partitions byunloading the set of data records, wherein the rebalance of the set ofdata records is improved based, at least in part, on one or morecharacteristics of the plurality of database partitions that aredetermined during the rebalance of the set of data records; the computerupdating the one or more characteristics during the rebalancing of theset of data records, wherein the one or more characteristics include oneor both of a) an average number of records per partition, and b) anaverage number of unique limit key values per partition; the computerloading the set of data records into the plurality of databasepartitions based, at least in part, on the one or more characteristics,wherein the one or more characteristics are used to direct therebalancing of the set of data records; the computer determining if afirst empty partition remains after loading the set of data records; andresponsive to determining that a first empty partition remains afterloading the set of data records, the computer performing limit keyextrapolation for the first empty partition by: the computer defining atleast one database partition of the plurality of database partitions byan upper limit key value based on a limit key value of a last loadeddata record; the computer determining a range of limit key values forthe plurality of database partitions from limit key definitions in adatabase; the computer determining if the limit key of the last loadedrecord is greater than a first upper limit key value of the first emptypartition, wherein the first upper limit key value of the first emptypartition was previously defined by the upper limit key value of acorresponding partition before a rebalance; responsive to adetermination that the upper limit key value of the last loaded recordis greater than the first upper limit key value of the first emptypartition, the computer redefining the first upper limit key value ofthe first empty partition by an extrapolated upper limit key valuebased, at least in part, on the range of limit key values; the computercalculating a remaining range of limit key values by subtracting agreatest limit key value of a reloaded set of data records from agreatest limit key value in the range of limit key values for theplurality of database partitions; the computer calculating an arithmeticaverage by dividing the remaining range of limit key values by a numberof empty partitions; and the computer calculating the first upper limitkey value of the first empty partition by adding the calculatedarithmetic average to the upper limit key value of the last loadedrecord.
 2. The method of claim 1, the method further comprising: thecomputer determining a grouping comprising a sub-set of data records inthe set of data records with a single limit key value; the computercalculating the average number of records per partition by dividing atotal number of data records in the set of data records by a totalnumber of database partitions in the plurality of database partitions;the computer determining a partition is filled based, at least in part,on a loaded grouping increasing the number of data records loaded into afirst partition, such that the number of data records loaded into thefirst partition is at least equal to the average number of records perpartition; and responsive to a determination that a partition is filled,the computer updating the average number of records per partition,wherein the updated average number of records per partition isdetermined by dividing a number of data records remaining to be loadedby a number of database partitions remaining to be filled.
 3. The methodof claim 1, the method further comprising: the computer determining agrouping comprising a sub-set of data records in the set of data recordswith a single limit key value; the computer determining a total numberof unique limit key values included in the set of data records; thecomputer calculating the average number of unique limit key values perpartition by dividing the total number of unique limit key values in theset of data records by a total number of database partitions in theplurality of database partitions; the computer determining a partitionis filled based, at least in part, on a loaded grouping increasing thenumber of unique limit key values loaded into a first partition, suchthat the number of unique limit key values loaded into the firstpartition is at least equal to the average number of unique limit keyvalues per partition; and responsive to a determination that a partitionis filled, the computer updating the average number of unique limit keyvalues per partition, wherein the updated average number of unique limitkey values per partition is determined by dividing a number of uniquelimit key values remaining to be loaded by a number of databasepartitions remaining to be filled.
 4. The method of claim 3, wherein thecomputer determining the total number of unique limit key valuescomprises: the computer unloading the set of data records using one ormore of: a) an index scan of a unique index of the plurality of databasepartitions, b) a table space scan, and c) a sort of the set of datarecords by ascending limit key value; and the computer counting thetotal number of unique limit key values using one of: a) a counter usingan index key during unloading, b) a hashing algorithm during unloading,and c) a counter during re-reading of the set of data records subsequentto unloading and sorting by ascending limit key values.
 5. The method ofclaim 1, wherein the step of the computer calculating an arithmeticaverage by dividing the remaining range of limit key values by thenumber of empty partitions comprises: the computer determining thearithmetic average based, at least in part, on a limit key column datatype, wherein the limit key column data type is one of: a) a numericlimit key column data type, wherein the arithmetic average is determinedby dividing the remaining range of limit key values by the number ofempty partitions; b) a date/timestamp limit key column data type,wherein the arithmetic average is determined by converting the remainingrange of limit key values from date/timestamp values into a number ofdays, and then dividing by the number of empty partitions; or c) acharacter limit key column data type, wherein, the arithmetic average isdetermined by converting the remaining range of limit key values fromcharacter values to floating point values, dividing by the number ofempty partitions, and then converting a resulting floating point valueto a character value.
 6. The method of claim 1, the method furthercomprising: the computer calculating a second upper limit key value of asecond empty partition by adding the calculated arithmetic average tothe first upper limit key value of the first empty partition.
 7. Acomputer program product for rebalancing partitioned data in a database,the computer program product comprising: a computer readable storagemedium and program instructions stored on the computer readable storagemedium, the program instructions comprising: program instructions toinitiate a rebalance of a set of data records included in a plurality ofdatabase partitions by unloading the set of data records, wherein therebalance of the set of data records is improved based, at least inpart, on one or more characteristics of the plurality of databasepartitions that are determined during the rebalance of the set of datarecords; program instructions to update the one or more characteristicsduring the rebalancing of the set of data records, wherein the one ormore characteristics include one or both of a) an average number ofrecords per partition, and b) an average number of unique limit keyvalues per partition; program instructions to load the set of datarecords into the plurality of database partitions based, at least inpart, on the one or more characteristics, wherein the one or morecharacteristics are used to direct the rebalancing of the set of datarecords; program instructions to determine if a first empty partitionremains after loading the set of data records; and responsive todetermining that a first empty partition remains after loading the setof data records, program instructions to perform limit key extrapolationfor the first empty partition by executing: program instructions todefine at least one database partition of the plurality of databasepartitions by an upper limit key value based on a limit key value of alast loaded data record; program instructions to determine a range oflimit key values for the plurality of database partitions from limit keydefinitions in a database; program instructions to determine if thelimit key of the last loaded record is greater than a first upper limitkey value of the first empty partition, wherein the first upper limitkey value of the first empty partition was previously defined by theupper limit key value of a corresponding partition before a rebalance;responsive to a determination that the upper limit key value of the lastloaded record is greater than the first upper limit key value of thefirst empty partition, program instructions to redefine the first upperlimit key value of the first empty partition by an extrapolated upperlimit key value based, at least in part, on the range of limit keyvalues; program instructions to calculate a remaining range of limit keyvalues by subtracting a greatest limit key value of a reloaded set ofdata records from a greatest limit key value in the range of limit keyvalues for the plurality of database partitions; program instructions tocalculate an arithmetic average by dividing the remaining range of limitkey values by a number of empty partitions; and program instructions tocalculate the first upper limit key value of the first empty partitionby adding the calculated arithmetic average to the upper limit key valueof the last loaded record.
 8. The computer program product of claim 7,the computer program product further comprising: program instructions todetermine a grouping comprising a sub-set of data records in the set ofdata records with a single limit key value; program instructions tocalculate the average number of records per partition by dividing atotal number of data records in the set of data records by a totalnumber of database partitions in the plurality of database partitions;program instructions to determine a partition is filled based, at leastin part, on a loaded grouping increasing the number of data recordsloaded into a first partition, such that the number of data recordsloaded into the first partition is at least equal to the average numberof records per partition; and responsive to a determination that apartition is filled, program instructions to update the average numberof records per partition, wherein the updated average number of recordsper partition is determined by dividing a number of data recordsremaining to be loaded by a number of database partitions remaining tobe filled.
 9. The computer program product of claim 7, the computerprogram product further comprising: program instructions to determine agrouping comprising a sub-set of data records in the set of data recordswith a single limit key value; program instructions to determine a totalnumber of unique limit key values included in the set of data records;program instructions to calculate the average number of unique limit keyvalues per partition by dividing the total number of unique limit keyvalues in the set of data records by a total number of databasepartitions in the plurality of database partitions; program instructionsto determine a partition is filled based, at least in part, on a loadedgrouping increasing the number of unique limit key values loaded into afirst partition, such that the number of unique limit key values loadedinto the first partition is at least equal to the average number ofunique limit key values per partition; and responsive to a determinationthat a partition is filled, program instructions to update the averagenumber of unique limit key values per partition, wherein the updatedaverage number of unique limit key values per partition is determined bydividing a number of unique limit key values remaining to be loaded by anumber of database partitions remaining to be filled.
 10. The computerprogram product of claim 9, wherein program instructions to determinethe total number of unique limit key values comprises: programinstructions to unload the set of data records using one or more of: a)an index scan of a unique index of the plurality of database partitions,b) a table space scan, and c) a sort of the set of data records byascending limit key value; and program instructions to count the totalnumber of unique limit key values using one of: a) a counter using anindex key during unloading, b) a hashing algorithm during unloading, andc) a counter during re-reading of the set of data records subsequent tounloading and sorting by ascending limit key values.
 11. The computerprogram product of claim 7, wherein the program instructions tocalculate an arithmetic average by dividing the remaining range of limitkey values by the number of empty partitions comprise: programinstructions to determine the arithmetic average based, at least inpart, on a limit key column data type, wherein the limit key column datatype is one of: a) a numeric limit key column data type, wherein thearithmetic average is determined by dividing the remaining range oflimit key values by the number of empty partitions; b) a date/timestamplimit key column data type, wherein the arithmetic average is determinedby converting the remaining range of limit key values fromdate/timestamp values into a number of days, and then dividing by thenumber of empty partitions; or c) a character limit key column datatype, wherein, the arithmetic average is determined by converting theremaining range of limit key values from character values to floatingpoint values, dividing by the number of empty partitions, and thenconverting a resulting floating point value to a character value. 12.The computer program product of claim 7, the computer program productfurther comprising: program instructions to calculate a second upperlimit key value of a second empty partition by adding the calculatedarithmetic average to the first upper limit key value of the first emptypartition.
 13. A computer system for rebalancing partitioned data in adatabase, the computer system comprising: one or more computerprocessors; one or more computer readable storage media; programinstructions stored on the computer readable storage media for executionby at least one of the one or more processors, the program instructionscomprising: program instructions to initiate a rebalance of a set ofdata records included in a plurality of database partitions by unloadingthe set of data records, wherein the rebalance of the set of datarecords is improved based, at least in part, on one or morecharacteristics of the plurality of database partitions that aredetermined during the rebalance of the set of data records; programinstructions to update the one or more characteristics during therebalancing of the set of data records, wherein the one or morecharacteristics include one or both of a) an average number of recordsper partition, and b) an average number of unique limit key values perpartition; program instructions to load the set of data records into theplurality of database partitions based, at least in part, on the one ormore characteristics, wherein the one or more characteristics are usedto direct the rebalancing of the set of data records; programinstructions to determine if a first empty partition remains afterloading the set of data records; and responsive to determining that afirst empty partition remains after loading the set of data records,program instructions to perform limit key extrapolation for the firstempty partition by executing: program instructions to define at leastone database partition of the plurality of database partitions by anupper limit key value based on a limit key value of a last loaded datarecord; program instructions to determine a range of limit key valuesfor the plurality of database partitions from limit key definitions in adatabase; program instructions to determine if the limit key of the lastloaded record is greater than a first upper limit key value of the firstempty partition, wherein the first upper limit key value of the firstempty partition was previously defined by the upper limit key value of acorresponding partition before a rebalance; responsive to adetermination that the upper limit key value of the last loaded recordis greater than the first upper limit key value of the first emptypartition, program instructions to redefine the first upper limit keyvalue of the first empty partition by an extrapolated upper limit keyvalue based, at least in part, on the range of limit key values; programinstructions to calculate a remaining range of limit key values bysubtracting a greatest limit key value of a reloaded set of data recordsfrom a greatest limit key value in the range of limit key values for theplurality of database partitions; program instructions to calculate anarithmetic average by dividing the remaining range of limit key valuesby a number of empty partitions; and program instructions to calculatethe first upper limit key value of the first empty partition by addingthe calculated arithmetic average to the upper limit key value of thelast loaded record.
 14. The computer system of claim 13, the computersystem further comprising: program instructions to determine a groupingcomprising a sub-set of data records in the set of data records with asingle limit key value; program instructions to calculate the averagenumber of records per partition by dividing a total number of datarecords in the set of data records by a total number of databasepartitions in the plurality of database partitions; program instructionsto determine a partition is filled based, at least in part, on a loadedgrouping increasing the number of data records loaded into a firstpartition, such that the number of data records loaded into the firstpartition is at least equal to the average number of records perpartition; and responsive to a determination that a partition is filled,program instructions to update the average number of records perpartition, wherein the updated average number of records per partitionis determined by dividing a number of data records remaining to beloaded by a number of database partitions remaining to be filled. 15.The computer system of claim 13, the computer system further comprising:program instructions to unload the set of data records using one or moreof: a) an index scan of a unique index of the plurality of databasepartitions, b) a table space scan, and c) a sort of the set of datarecords by ascending limit key value; program instructions to count atotal number of unique limit key values in the set of data records usingone of: a) a counter using an index key during unloading, b) a hashingalgorithm during unloading, and c) a counter during re-reading of theset of data records subsequent to unloading and sorting by ascendinglimit key values; program instructions to determine a groupingcomprising a sub-set of data records in the set of data records with asingle limit key value; program instructions to calculate the averagenumber of unique limit key values per partition by dividing the totalnumber of unique limit key values in the set of data records by a totalnumber of database partitions in the plurality of database partitions;program instructions to determine a partition is filled based, at leastin part, on a loaded grouping increasing the number of unique limit keyvalues loaded into a first partition, such that the number of uniquelimit key values loaded into the first partition is at least equal tothe average number of unique limit key values per partition; andresponsive to a determination that a partition is filled, programinstructions to update the average number of unique limit key values perpartition, wherein the updated average number of unique limit key valuesper partition is determined by dividing a number of unique limit keyvalues remaining to be loaded by a number of database partitionsremaining to be filled.
 16. The computer system of claim 13, thecomputer system further comprising: program instructions to calculate asecond upper limit key value of a second empty partition by adding thecalculated arithmetic average to the first upper limit key value of thefirst empty partition.
 17. The computer program system of claim 13, theprogram instructions further comprising: program instructions todetermine a grouping comprising a sub-set of data records in the set ofdata records with a single limit key value; program instructions todetermine a total number of unique limit key values included in the setof data records; program instructions to calculate the average number ofunique limit key values per partition by dividing the total number ofunique limit key values in the set of data records by a total number ofdatabase partitions in the plurality of database partitions; programinstructions to determine a partition is filled based, at least in part,on a loaded grouping increasing the number of unique limit key valuesloaded into a first partition, such that the number of unique limit keyvalues loaded into the first partition is at least equal to the averagenumber of unique limit key values per partition; and responsive to adetermination that a partition is filled, program instructions to updatethe average number of unique limit key values per partition, wherein theupdated average number of unique limit key values per partition isdetermined by dividing a number of unique limit key values remaining tobe loaded by a number of database partitions remaining to be filled. 18.The computer program product of claim 13, wherein the programinstructions to calculate an arithmetic average by dividing theremaining range of limit key values by the number of empty partitionscomprise: program instructions to determine the arithmetic averagebased, at least in part, on a limit key column data type, wherein thelimit key column data type is one of: a) a numeric limit key column datatype, wherein the arithmetic average is determined by dividing theremaining range of limit key values by the number of empty partitions;b) a date/timestamp limit key column data type, wherein the arithmeticaverage is determined by converting the remaining range of limit keyvalues from date/timestamp values into a number of days, and thendividing by the number of empty partitions; or c) a character limit keycolumn data type, wherein, the arithmetic average is determined byconverting the remaining range of limit key values from character valuesto floating point values, dividing by the number of empty partitions,and then converting a resulting floating point value to a charactervalue.